---
import { DocsExampleRunner } from './DocsExampleRunner';
import type { ExampleType } from '@features/example-generator/types';
import ExampleRunnerContainer from '@features/example-runner/components/ExampleRunnerContainer.astro';
import { getPageNameFromPath } from '@features/docs/utils/urlPaths';
import { getFrameworkFromPath } from '@features/docs/utils/urlPaths';
import { getIsDev } from '@utils/env';

interface Props {
    title: string;
    name: string;
    type: ExampleType;
    exampleHeight?: number;
}

const { title, name, type, exampleHeight } = Astro.props as Props;

const framework = getFrameworkFromPath(Astro.url.pathname);
const pageName = getPageNameFromPath(Astro.url.pathname);
const isDev = getIsDev();
---

<ExampleRunnerContainer exampleHeight={exampleHeight} pageName={pageName} exampleName={name}>
    <DocsExampleRunner
        client:only
        title={title}
        name={name}
        exampleType={type ?? 'generated'}
        exampleHeight={exampleHeight}
        framework={framework}
        pageName={pageName}
        isDev={isDev}
    />
</ExampleRunnerContainer>
